package com.hjf.ditubiaozhu.base;

import com.j256.ormlite.field.DatabaseField;

import java.io.Serializable;



/**
 * Created by hejianfeng on 16/12/31.
 * 公共bean的基类
 */

public class Base<E extends Base> implements Serializable, Comparable<E> {
    @DatabaseField
    protected long created;//创建时间
    @DatabaseField
    protected long updated;//修改时间
    @DatabaseField(generatedId = true)
    protected Integer id;//id
    // @DatabaseField
    protected User createUser;//创建者
    @DatabaseField
    protected String shortName;//段名
    @DatabaseField
    protected String name;//普通名
    @DatabaseField
    protected String notes;//备注

    public int typeInt;

    public int getTypeInt() {
        return typeInt;
    }

    public void setTypeInt(int typeInt) {
        this.typeInt = typeInt;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public long getCreated() {
        return created;
    }

    public void setCreated(long created) {
        this.created = created;
    }

    public long getUpdated() {
        return updated;
    }

    public void setUpdated(long updated) {
        this.updated = updated;
    }

    public Integer getId() {

        return id == null ? 0 : id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public User getCreateUser() {
        return createUser;
    }

    public void setCreateUser(User createUser) {
        this.createUser = createUser;
    }

    public String getShortName() {
        return shortName;
    }

    public void setShortName(String shortName) {
        this.shortName = shortName;
    }

    @Override
    public String toString() {
        return "Base{" +
                "created=" + created +
                ", updated=" + updated +
                ", id=" + id +
                ", createUser=" + createUser +
                ", shortName='" + shortName + '\'' +
                ", name='" + name + '\'' +
                ", notes='" + notes + '\'' +
                '}';
    }

    /**
     * 默认实现更新时间排序
     *
     * @param another
     * @return
     */
    @Override
    public int compareTo(E another) {
        //return (int) (another.getUpdated() - updated);
        return getTypeInt() - another.getTypeInt();
    }
}
